﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Assignment_5_Amanda_Boström.ContactFiles
{
    public class Address
    {
        // Instance variables
        private string m_street;
        private string m_zipCode;
        private string m_city;
        private Countries m_country;

        // Constructors
        /// <summary>
        /// Default constructor, calling another constructor(which takes three parameters)
        /// </summary>
        public Address() : this(string.Empty, string.Empty, string.Empty) {}
        /// <summary>
        /// Constructor taking three parameters, calling next constructor
        /// (which takes four parameters)
        /// </summary>
        /// <param name="street"></param>
        /// <param name="zip"></param>
        /// <param name="city"></param>
        public Address(string street, string zip, string city) : this(street, zip, city, Countries.Sverige) {}
        /// <summary>
        /// Constructor taking four parameters, all constructor code for
        /// the class is contained here.
        /// </summary>
        /// <param name="street"></param>
        /// <param name="zip"></param>
        /// <param name="city"></param>
        /// <param name="country"></param>
        public Address(string street, string zip, string city, Countries country) 
        {
            m_street = street;
            m_zipCode = zip;
            m_city = city;
            m_country = country;
        }

        // Properties
        public string Street 
        {
            get { return m_street; }
            set { m_street = value;} 
        }
        public string City
        {
            get { return m_city; }
            set { m_city = value; }
        }
        public string ZipCode
        {
            get { return m_zipCode; }
            set { m_zipCode = value; }
        }
        public Countries Country
        {
            get { return m_country; }
            set { m_country = value; }
        }

        //Methods
        /// <summary>
        /// This function simply deletes the '_'s from the country names as 
        /// saved in the enum
        /// </summary>
        /// <returns></returns>
        public string GetCountryString()
        {
            string strCountry = m_country.ToString();
            strCountry = strCountry.Replace("_", " ");
            return strCountry;
        }
        /// <summary>
        /// Overrides the ToString-method to return a string made of the address detail,
        /// formatted in one line.
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            string strOut = string.Format("{0, -25} {1, -8} {2, -10} {3}", m_street, m_zipCode, m_city, GetCountryString());
            return strOut;
        }

    }
}
